//  人脸识别信息填写控制模块
import {
    viewInit,
    djsfunc
} from '../views/infoView.js';


var $verifyBtn, $phone, $verification_code, $name, $submit_btn,$frId;
$(document).on("pageinit", "#infoPage", controllerInit);

// 控制器初始化
function controllerInit() {
    initValue();
    viewInit();
    bindEvent();
}

//
function submitFuc () {
    if($submit_btn.hasClass("weui-btn_disabled")){
        return;
    }else{
        sessionStorage.setItem("face_name",$name.val());
        sessionStorage.setItem("face_id",$frId.val());
        sessionStorage.setItem("face_phone",$phone.val());
        location.href = "./faceDetect.html";
    }
}

// 获取验证码
function getVerifyCode() {
    if ($verifyBtn.hasClass("weui-btn_plain-disabled")) {
        return;
    } else {
        djsfunc();
        $verifyBtn.attr("class", "weui-btn_plain-disabled");
        var parameters = {};
        parameters.lodinId = $phone.val();
        parameters.position = "2";
        parameters.sendType = "1";
        $.post(duanxin_URL, parameters, smsCallBack);
    }
}

// 
function smsCallBack(msgData) {
    console.dir(msgData);
}

// 绑定事件
function bindEvent() {
    $verifyBtn.on("touchstart", getVerifyCode)
    $submit_btn.on("touchend",submitFuc)
}

// 变量初始化
function initValue() {
    $verifyBtn = $("#verifyBtn");
    $phone = $("#phone");
    $verification_code = $("#verification_code");
    $name = $("#name");
    $submit_btn = $("#submit_btn");
    $frId = $("#frId");
}